$(function() {
	var token = localStorage.phone;
	var content = '';
	var order_id = localStorage.order_id;
	var reasonAll = '';
	$('.btn_comfirm').click(function() {
		content = $('.text-input').val();
		$('input[type=checkbox]').each(function() {
			if($(this).prop('checked')) {
				reasonAll += $(this).val() + ',';
			}

		});
		reasonAll = reasonAll + content;
		if(reasonAll != '') {
			$.ajax({
				url: "https://newapp.icandrive.cn/api/report.php",
				dataType: 'json',
				type: 'post',
				data: {
					token: token,
					reasonAll: reasonAll,
					order_id: order_id
				},
				success: function(data) {
					console.log(data);
					if(data.status == 200) {
						layer.msg('举报成功');
						setTimeout(function() {
							history.back();
						},3000)
					}
				else if(data.status == 450) {
						layer.msg("您已经举报过了");
                        setInterval(function(){
                	 	window.location.href="../index/index.html"
                	 },3000);
                    }
				},
				error: function() {
					layer.msg('系统繁忙', function() {
						history.go(0)
					}, 3000);
				}

			})
			$(this).unbind();
		} else {
			layer.msg('请至少选择一种或输入理由');
		}
	})
})
